#pragma once
#include <stdlib.h>
#include <string>

namespace encode_util {
// setlocale(LC_CTYPE, "");
std::string UnicodeToUTF8(const std::wstring &wstr);

std::wstring UTF8ToUnicode(const std::string &str);

std::string UnicodeToANSI(const std::wstring &wstr);

std::wstring ANSIToUnicode(const std::string &str);

std::string UTF8ToANSI(const std::string &str);

std::string ANSIToUTF8(const std::string &str);

// 注意：此接口有几率将UTF8的字符串误判为GBK编码，建议调用IsGbk先调用IsUtf8来判断。
bool IsGbk(const u_char* data, size_t len, int* character_count = NULL);

bool MaskGbk(u_char* data, size_t len, int character_count, int mask_front_count, int mask_back_count);

bool IsUtf8(const u_char* data, size_t len, int* character_count = NULL);

bool MaskUtf8(u_char* data, size_t len, int character_count, int mask_front_count, int mask_back_count);

// ucs2_len为ucs2字符的个数，而不是字节的个数
void Ucs2ToUtf8(std::string& out_str, const uint8_t* ucs2_data, size_t ucs2_len, bool big_endian = false);

void GbkToUtf8(std::string& out_str, const char* gbk_data);

std::string Base64Encode(const uint8_t* text, uint32_t text_len);

std::string Base64Decode(const uint8_t* code, uint32_t code_len);

bool isalpha (wchar_t ch);
}  // namespace encode_util